Skip to content

[CORE] added unreachable unwrap function to Option - #134007

Closed
Cr0a3 wants to merge 2 commits into
rust-lang:masterfrom
Cr0a3:master
Closed

Cr0a3 wants to merge 2 commits into
rust-lang:masterfrom
Cr0a3:master

Conversation

@Cr0a3

@Cr0a3 Cr0a3 commented Dec 7, 2024

Copy link
Copy Markdown

Hi,
In this PR i added a function to Option which throws an unreachable exception, if the internal value is None.

Would this have use cases?

Yes, I want a feature like that for a very long time.
It would make development of some of my codegen libs easier.

Best wishes,
Toni

@rustbot

rustbot commented Dec 7, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @workingjubilee (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 7, 2024
@rust-log-analyzer

This comment has been minimized.

@cyrgani

cyrgani commented Dec 7, 2024

Copy link
Copy Markdown
Contributor

See rust-lang/rfcs#3706 for a longer discussion of such a function and alternatives too.

@workingjubilee workingjubilee added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2024
@workingjubilee

Copy link
Copy Markdown
Member

Please file an ACP.

@workingjubilee

Copy link
Copy Markdown
Member

As unwrap_unchecked exists, which is equivalent to a match which uses unreachable_unchecked on the None branch, I really don't think this is a good function to add as it just adds more confusion about what can be done with an option. You can use an extension trait to add your particular personal functions that you want.

If you didn't know about those functions before I told you about them, that's my point: the API is already too big for it to be easily learnable.

@Cr0a3

Cr0a3 commented Dec 8, 2024

Copy link
Copy Markdown
Author

As unwrap_unchecked exists, which is equivalent to a match which uses unreachable_unchecked on the None branch, I really don't think this is a good function to add as it just adds more confusion about what can be done with an option. You can use an extension trait to add your particular personal functions that you want.

If you didn't know about those functions before I told you about them, that's my point: the API is already too big for it to be easily learnable.

Ok, then I am going to close this pr

@Cr0a3 Cr0a3 closed this Dec 8, 2024
@clarfonthey clarfonthey removed the S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants